import { message } from "antd";
import {
  ShowFranchiseePage,
  SelectFinance,
  AndUpdateFranchisee,
  xiugai
} from "../../api/JiaMeng";
const obj = {
  // 加盟商管理table
  JiaMengData: [],
  async showAllFran1() {
    const data = await ShowFranchiseePage();
    if (data.code !== 200) {
      return message.error("网络异常！");
    }
    console.log(data)
    data.data.forEach((v) => {
      v.key = v.id;
    });
    this.JiaMengData = data.data;
  },
  //结账管理table
  JieZhangData: [],
  async showAllFran() {
    const data = await SelectFinance();
    if (data.code !== 200) {
      return message.error("网络异常！");
    }
    // console.log(data)
    data.data.forEach((v) => {
      v.key = v.id;
    });
    this.JieZhangData = data.data;
  },
  //添加操作
  //   Tianjia: [],
  async tianjiadadet(obj) {
    try {
      const data = await AndUpdateFranchisee(obj);
      if (data.code !== 200) {
        return message.error("网络异常！");
      }
      console.log(data, 111111111);
      this.showAllFran1();
      //   data.data.forEach((v, i) => {
      //     v.key = i;
      //   });
      //   this.tianjiadadet = data.data;
    } catch (error) {
      console.log(error);
    }
  },
  async xiugaidadet(obj) {
    try {
      const data = await xiugai(obj);
      if (data.code !== 200) {
        return message.error("网络异常！");
      }
    //   console.log(data, 111111111);
      this.showAllFran1();
      //   data.data.forEach((v, i) => {
      //     v.key = i;
      //   });
      //   this.tianjiadadet = data.data;
    } catch (error) {
      console.log(error);
    }
  },

};
export default obj;
